package com.never.adapter;
//mark
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.never.R;

public class ListAdapter extends BaseAdapter {

	private Cursor cursor;
	private Context context;
	private int position;

	public ListAdapter(Context _context, Cursor _cursor) {
		cursor = _cursor;
		context = _context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return cursor.getCount();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		convertView = LayoutInflater.from(context).inflate(R.layout.playlist,
				null);
		cursor.moveToPosition(position);
		TextView tv_listname = (TextView) convertView
				.findViewById(R.id.playlist_textView_name);
		String strname = cursor.getString(1);
		if (cursor.getString(0).length() > 15) {
			strname = strname.substring(0, 11) + "...";
		}
		tv_listname.setText(strname);
		return convertView;
	}

}
